
#ifndef COMMON_H_H
#define COMMON_H_H

#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include "dataproc.h"
#include "pulse.h"
#include "str_ext.h"
//#define U8_GEN
#define UCHAR_GEN
#define BYTE_GEN
//#define UINT_GEN
#include "mytype.h"

#ifdef __cplusplus
extern "C"
{
#endif

/*****************************************************************************
* @brief   global dbg
*****************************************************************************/
#define DBG_EN 1

/*****************************************************************************
* @brief   moudle dbg
*****************************************************************************/
#define CAN_DBG_EN 0
#define MB_DBG_EN 0
#define OS_API_DBG_EN 1
#define FLASH_DBG_EN 1
#define FILE_DBG_EN 1
#define MALLOC_DBG_EN 0

/*****************************************************************************
* @brief print
*****************************************************************************/
void sys_hw_printf(char* fmt, ...);
void sys_hw_puts(const char *str);

/*****************************************************************************
* @brief   dbg print
*****************************************************************************/
#if DBG_EN > 0
#define dbg_print sys_hw_printf
#define dbg_puts sys_hw_puts
#define dbg_notice gui_notice
#define dbg_u8_print mem_u8_disp
#define dbg_u16_print mem_u16_disp
#define dbg_u32_print mem_u32_disp
#else
#define dbg_print(...)
#define dbg_puts(...)
#define dbg_notice(...)
#define dbg_u8_print(...)
#define dbg_u16_print(...)
#define dbg_u32_print(...)
#endif

#if (DBG_EN + MB_DBG_EN) > 1
#define mb_dbg_print sys_hw_printf
#define mb_dbg_puts sys_hw_puts
#else
#define mb_dbg_print(...)
#define mb_dbg_puts(...)
#endif

#if (DBG_EN + CAN_DBG_EN) > 1
#define can_dbg_print sys_hw_printf
#define can_dbg_puts sys_hw_puts
#else
#define can_dbg_print(...)
#define can_dbg_puts(...)
#endif

#if (DBG_EN + OS_API_DBG_EN) > 1
#define api_dbg_print sys_hw_printf
#define api_dbg_puts sys_hw_puts
#else
#define api_dbg_print(...)
#define api_dbg_puts(...)
#endif

#if (DBG_EN + FLASH_DBG_EN) > 1
#define flash_dbg_print sys_hw_printf
#define flash_dbg_puts sys_hw_puts
#else
#define flash_dbg_print(...)
#define flash_dbg_puts(...)
#endif

#if (DBG_EN + FILE_DBG_EN) > 1
#define file_dbg_print sys_hw_printf
#define file_dbg_puts sys_hw_puts
#else
#define file_dbg_print(...)
#define file_dbg_puts(...)
#endif

#if (DBG_EN + MALLOC_DBG_EN) > 1
#define malloc_dbg_print sys_hw_printf
#define malloc_dbg_puts sys_hw_puts
#else
#define malloc_dbg_print(...)
#define malloc_dbg_puts(...)
#endif

#define dbg_put_line() dbg_puts("\n===========================================================\n");

/*****************************************************************************
* @brief   memory display
*****************************************************************************/
#define MEM_U8_DISP
	void mem_u8_disp(const void *head, const void *dat, int len, int line);
	void mem_u16_disp(const void *head, const void *dat, int len, int line);
	void mem_u32_disp(const void *head, const void *dat, int len, int line);
	const char *file_name_get(const char *file_path);
	const char *file_type_get(const char *file_path);
	
#define DBG_FILE file_name_get(__FILE__)
#define DBG_LINE __LINE__

/*****************************************************************************
* @brief   notice
*****************************************************************************/
void gui_notice(const char *);

#include "dbg_assert.h"
#include "dbg_func.h"

#ifdef __cplusplus
}
#endif

#endif /* COMMON_H_H */
